 package com.coc.dao;
 
 import com.coc.bean.CcEloUser;
 import com.coc.bean.CocServer;
 import com.coc.bean.CocServer2;
 import com.coc.bean.CocSetting;
 import com.coc.bean.FileVersion;
 import java.util.List;
 import org.apache.commons.logging.Log;
 import org.springframework.orm.hibernate3.HibernateTemplate;
 import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
 
 public class EloUserDAOImpl extends HibernateDaoSupport
   implements EloUserDAO
 {
   public CcEloUser findBySNSID(String fbid)
   {
     try
     {
       List li = getHibernateTemplate().find(
         "from CcEloUser where snsid='" + 
         fbid + "'");
       if ((li != null) && (li.size() > 0))
         return (CcEloUser)li.get(0);
     } catch (Exception e) {
       this.logger.error("PcUserDAOHiberante--findByFBID", e);
     }
     return null;
   }
   public CcEloUser findBySNSName(String name) {
     try {
       List li = getHibernateTemplate().find(
         "from CcEloUser where name='" + 
         name + "'");
       if ((li != null) && (li.size() > 0))
         return (CcEloUser)li.get(0);
     } catch (Exception e) {
       this.logger.error("PcUserDAOHiberante--findBySNSName", e);
     }
     return null;
   }
   public List findMatch(int cup, int lv, int htlv) {
     try {
       return getHibernateTemplate().find("");
     } catch (Exception e) {
       e.printStackTrace();
     }return null;
   }
 
   public boolean saveOrUpdate(CcEloUser eu)
   {
     try {
       getHibernateTemplate().saveOrUpdate(eu);
     } catch (Exception e) {
       e.printStackTrace();
       return false;
     }
     return true;
   }
 
   public CocSetting findcs() {
     try {
       return (CocSetting)getHibernateTemplate().get(CocSetting.class, Integer.valueOf(1));
     } catch (Exception e) {
       this.logger.error("EloUserDAOImpl--findById", e);
     }return null;
   }
 
   public void savecs(CocSetting cs)
   {
     try
     {
       getHibernateTemplate().saveOrUpdate(cs);
     } catch (Exception e) {
       e.printStackTrace();
     }
   }
 
   public FileVersion findFVByID(int id)
   {
     try {
       return (FileVersion)getHibernateTemplate().get(
         FileVersion.class, Integer.valueOf(1));
     } catch (Exception e) {
       this.logger.error("SeaUserDAOImpl--findById", e);
     }return null;
   }
 
   public List findFVByTypes(int types)
   {
     try
     {
       return getHibernateTemplate().find(
         "from FileVersion where types=" + types);
     }
     catch (Exception e) {
       this.logger.error("UserDAOHiberante--NoSql", e);
     }
     return null;
   }
 
   public void saveFV(FileVersion fv)
   {
     try {
       getHibernateTemplate().saveOrUpdate(fv);
     } catch (Exception e) {
       this.logger.error("PcUserDAOHiberante--saveOrUpdate", e);
     }
   }
 
   public FileVersion findFVByFileName(String filename)
   {
     try {
       List li = getHibernateTemplate().find("from FileVersion where filename='" + filename + "'");
       if (li.size() > 0) {
         return (FileVersion)li.get(0);
       }
       return null;
     }
     catch (Exception e) {
       this.logger.error("UserDAOHiberante--NoSql", e);
     }
     return null;
   }
 
   public List findSVByTypes(int types, int status)
   {
     try {
       return getHibernateTemplate().find(
         "from CocServer where types=" + types + " and status=" + status);
     } catch (Exception e) {
       this.logger.error("UserDAOHiberante--NoSql", e);
     }
     return null;
   }
 
   public void delSV(CocServer sv)
   {
     try {
       getHibernateTemplate().delete(sv);
     } catch (Exception e) {
       this.logger.error("PcUserDAOHiberante--saveOrUpdate", e);
     }
   }
 
   public void saveSV(CocServer sv)
   {
     try
     {
       getHibernateTemplate().saveOrUpdate(sv);
     } catch (Exception e) {
       this.logger.error("PcUserDAOHiberante--saveOrUpdate", e);
     }
   }
 
   public List findSVByTypes2(int types, int status)
   {
     try {
       return getHibernateTemplate().find(
         "from CocServer2 where types=" + types + " and status=" + status);
     } catch (Exception e) {
       this.logger.error("UserDAOHiberante--NoSql", e);
     }
     return null;
   }
 
   public void delSV2(CocServer2 sv)
   {
     try {
       getHibernateTemplate().delete(sv);
     } catch (Exception e) {
       this.logger.error("PcUserDAOHiberante--saveOrUpdate", e);
     }
   }
 
   public void saveSV2(CocServer2 sv)
   {
     try
     {
       getHibernateTemplate().saveOrUpdate(sv);
     } catch (Exception e) {
       this.logger.error("PcUserDAOHiberante--saveOrUpdate", e);
     }
   }
 
   public CcEloUser findByID(int id) {
     try {
       return (CcEloUser)getHibernateTemplate().get(CcEloUser.class, Integer.valueOf(id));
     } catch (Exception e) {
       this.logger.error("CcEloUser--findByID", e);
     }return null;
   }
 
   public CcEloUser findMatch(long savetime, long lastaction, long lastelo, int cupfrom, int cupto)
   {
     String hql = "from CcEloUser where savetime < ? and lastaction < ? and lastelotime < ? and cup > ? and cup < ? order by rand()";
     List li = getHibernateTemplate().find(hql, new Object[] { Long.valueOf(savetime), Long.valueOf(lastaction), Long.valueOf(lastelo), Integer.valueOf(cupfrom), Integer.valueOf(cupto) });
     if ((li != null) && (li.size() > 0)) {
       return (CcEloUser)li.get(0);
     }
     return null;
   }
 }

/* Location:           C:\Work\WorkSpace\classes\
 * Qualified Name:     com.coc.dao.EloUserDAOImpl
 * JD-Core Version:    0.6.2
 */